<HTML><HEAD><TITLE>compile(++File)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Predicate Database and Compiler</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>compile(++File)</H1>
Compile specified file, or list of files, with default options
<DL>
<DT><EM>File</EM></DT>
<DD>Atom, structure or string, or a list of them.
</DD>
</DL>
<H2>Description</H2>

    Compiles the specified ECLiPSE source file or list of source files.
    The default options are used, and the resulting code is directly
    loaded into memory and ready for execution.  See compile/2 for details.

<H3>Modes and Determinism</H3><UL>
<LI>compile(++) is det
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>File is not instantiated.
<DT><EM>(5) type error </EM>
<DD>File is instantiated, but not to an atom or string, or a list of atoms or strings.
<DT><EM>(61) inconsistent tool redefinition </EM>
<DD>A predicate that was already defined is later declared to be a tool.
<DT><EM>(62) inconsistent procedure redefinition </EM>
<DD>Illegal attempt to change a predicate's properties like: tool, dynamic, demon, parallel, calling convention.
<DT><EM>(82) trying to access a locked module </EM>
<DD>The module in which the clauses should be compiled is locked.
<DT><EM>(94) trying to redefine an existing imported procedure </EM>
<DD>There is already am imported predicate of the same name.
<DT><EM>(130) syntax error: illegal head </EM>
<DD>The head of a clause is not an atom or a compound term.
<DT><EM>(131) syntax error: illegal goal </EM>
<DD>A subgoal in the body of a clause is not an atom, a compound term or a variable.
<DT><EM>(134) procedure clauses are not consecutive </EM>
<DD>The clauses of a procedure are not consecutive.
<DT><EM>(137) trying to redefine a procedure with another type </EM>
<DD>A procedure which was previously referenced as built-in or external is now defined as a regular one, or vice versa.
<DT><EM>(139) compiled or dumped file message </EM>
<DD>This event is invoked at the end of each compiled file, by default it prints the compilation time and size of compiled code.
<DT><EM>(143) compiled query failed </EM>
<DD>A query in the compiled file has failed. This is by default ignored and the compilation continues.
<DT><EM>(145) procedure being redefined in another file </EM>
<DD>A procedure is being redefined in another file than the original one.
<DT><EM>(147) compilation aborted </EM>
<DD>This event is raised just before a compilation is aborted because of an error.
<DT><EM>(148) bad pragma </EM>
<DD>An unrecognised pragma was used in the code.
<DT><EM>(171) File does not exist :  </EM>
<DD>File does not exist.
</DL>
<H2>Examples</H2>
<PRE>
Success:
   [hanoi].         % compiles the file hanoi.pl

   [eclipse]: sh('cat file1').
   p:-q(hello).
   yes.
   [eclipse]: sh('cat file2').
   q(X) :- writeln(X).
   yes.
   [eclipse]: compile(user), p.
    p :- writeln(hi).
    user compiled 92 bytes in 0.00 seconds
   hi
   yes.
   [eclipse]: compile([file1, file2]), p.
   /home/lp/user/file1 compiled 32 bytes in 0.02 seconds
   /home/lp/user/file2 compiled 92 bytes in 0.00 seconds
   hello
   yes.


   % example showing use of relative pathnames.
   [eclipse]: sh('ls -FR /home/lp/user/pl').
   a.pl        util/

   /home/lp/user/pl/util:
   b.pl        c.pl

   yes.
   [eclipse]: sh('cat /home/lp/user/pl/a.pl').
   :- compile('util/b').
   p.

   yes.
   [eclipse]: compile('/home/lp/user/pl/a').
   /home/lp/user/pl/util/b.pl compiled 92 bytes in 0.00 seconds
   /home/lp/user/pl/a.pl compiled 28 bytes in 0.00 seconds
   yes.

Error:
   compile(F).            (Error 4).
   compile(file1/1).      (Error 5).
   compile(file).         (Error 171).
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/compiler/compile-2.html">compile / 2</A>, <A HREF="../../kernel/compiler/compile_stream-1.html">compile_stream / 1</A>, <A HREF="../../kernel/compiler/compile_term-1.html">compile_term / 1</A>, <A HREF="../../kernel/compiler/compile_term-2.html">compile_term / 2</A>, <A HREF="../../kernel/compiler/ensure_loaded-1.html">ensure_loaded / 1</A>, <A HREF="../../kernel/compiler/lib-1.html">lib / 1</A>, <A HREF="../../kernel/modules/use_module-1.html">use_module / 1</A>, <A HREF="../../kernel/directives/pragma-1.html">pragma / 1</A>, <A HREF="../../lib/fcompile/fcompile-1.html">fcompile : fcompile / 1</A>
</BODY></HTML>
